﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Blizzard.Contracts;
using Blizzard.Interceptors;

namespace Blizzard.Test.DataObjects
{   
    
    /// <summary>
    /// y is an independent object (has no relation with any other IDataObject)
    /// But it has two property of type enum, its purpose is to test
    /// the enum data type persistance and load by means of a delegate
    /// </summary>
    [Mapper(Table = "person")]
    public class Person : IDataObject
    {
        private Interceptor _interceptor;

        [Mapper(Field = "Id", IsIdentityColumn = true)]
        public int Id { get; set; }

        private string _name;
        [Mapper(Field = "Name")]
        public string Name
        {
            get
            {
                _interceptor.Intercept(this, "Name", false);
                return _name;
            }
            set
            {
                _interceptor.Intercept(this, "Name", true, _name, value);
                _name = value;
            }
        }

        
     


        private GBU character;
        //In MS Access "Character" is a reserved word. but this can also be used for sqlServer
        [Mapper(Field = "[Character]")]
        public GBU Character
        {
            get 
            {
                _interceptor.Intercept(this, "Character", false);
                return character; 
            }
            set 
            {
                _interceptor.Intercept(this, "Character", true, character, value);
                character = value; 
            }
        }

      


        private Color favoriteColor;
        
        [Mapper(Field = "[Favorite Color]")]
        public Color FavoriteColor
        {
            get 
            {
                _interceptor.Intercept(this, "FavoriteColor", false);
                return favoriteColor; 
            }
            set 
            {
                _interceptor.Intercept(this, "FavoriteColor", true, favoriteColor, value);
                favoriteColor = value; 
            }
        }



         public Container.BlizzardManager Manager
         {
             set { _interceptor = new Interceptor(value); }
         }
    }
}
